package blog.handler;

import blog.vo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

// 对加了Controller注解的方法进行拦截
@RestControllerAdvice
public class AllExceptionHandler {

    // 处理Exception.class异常
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result doException(Exception ex){
        ex.printStackTrace();

        return Result.fail(-9999,"后端接口异常");
    }

}
